$(function () {
    function renderMap() {
        //新建一个地图上点
        var points = [
            { "lng": 104.061471, "lat": 30.592201, "url": "#", "id": "成都雷兽互动科技有限公司", "name": "成都市高新区府城大道西段399号(天府新谷)8号楼二单元1305号", "phone": "028-85218082" }
        ];
        //116.29375,39.837923
        //创建标注点并添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                var label1 = points[i].name;
                var label = new BMap.Label(label1, { offset: new BMap.Size(15, -25) });
                marker.setLabel(label);
                map.addOverlay(marker);  //将标注点添加到地图上
                //marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }
        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">'
                + '<li style="line-height: 26px;font-size: 15px;">'
                + '<span style="width: 50px;display: inline-block;">名称：</span>' + point.id + '</li>'
                + '<li style="line-height: 26px;font-size: 15px;">'
                + '<span style="width: 50px;display: inline-block;">地址：</span>' + point.name + '</li>'
                + '<li style="line-height: 26px;font-size: 15px;">'
                + '<span style="width: 50px;display: inline-block;">电话：</span>' + point.phone + '</li>'
                + '<li style="line-height: 26px;font-size: 15px;"><span style="width: 50px;display: inline-block;">查看：</span><a href="' + point.url + '">详情</a></li>'
                + '</ul>';
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }

        //创建地图
        var map = new BMap.Map('map_container');
        map.centerAndZoom(new BMap.Point(104.061471, 30.592201), 17);  // 设置中心点
        map.enableScrollWheelZoom(true);
        map.setMapStyleV2({
            styleId: "c2fc9a60f7d89583cf029ed18788697f"
        })
        addMarker(points);
    }
})